<?php

class hukd_widget
{

	function add_stylesheets()
	{
		wp_register_style('hukdwidget', '/wp-content/plugins/wp-hukd/stylesheets/widget.css');
		wp_enqueue_style( 'hukdwidget');        
	}
	
	function widget()
	{
		include('widget/widget.php');
	}
	
	function control()
	{	
		$can_write_to_cache=is_writable('../'.CACHE_PATH);
	
		
	
		include('widget/control.php');
	}

	function activate()
	{
	
		$data['forum'] = 'all';
	    $data['category'] = 'all';
	    $data['search'] = '';
	    $data['results_per_page'] = '10'; 
	    $data['order'] = 'hot'; 
	   	$data['min_temp'] = '100'; 
	   	$data['heading_text'] = 'Latest Deals'; 
	   
	    update_option('wp-hukd', $data);
	    
	    
		if(!file_exists('../'.CACHE_PATH))
		{
			mkdir('../'.CACHE_PATH);
			chmod('../'.CACHE_PATH,0775);
		}

	}
	
	function deactivate()
	{
    	delete_option('wp-hukd');
	}

	function add_admin_menu()
	{
	
		add_options_page("HUKD", "HUKD", 1, "HUKD", array('hukd_widget',"admin_page"));  
	}
	
	function admin_page()
	{
		include('widget/admin_page.php');
	}
}


add_action('admin_menu', array('hukd_widget','add_admin_menu'));  


add_action('wp_print_styles', array('hukd_widget','add_stylesheets'));

register_sidebar_widget('HUKD Latest Deals',array('hukd_widget','widget'));
register_widget_control('HUKD Latest Deals', array('hukd_widget','control'));


?>